//
//  IndexFourItemSizeCell.m
//  YunFu
//
//  Created by Bager on 2018/8/30.
//  Copyright © 2018年 yunfu. All rights reserved.
//

#import "IndexFourItemSizeCell.h"

@implementation IndexFourItemSizeCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setViews];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setViews
{
    [self addSubview:self.img];
    [self addSubview:self.name];
}

- (UIImageView *)img
{
    if (!_img)
    {
        _img = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, (kScreenWidth - kPublicMargin * 2) / 4.0 - 30, 40)];
        _img.contentMode = UIViewContentModeCenter;
        _img.layer.masksToBounds = YES;
    }
    return _img;
}

- (UILabel *)name
{
    if (!_name)
    {
        _name = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, (kScreenWidth - kPublicMargin * 2) / 4.0, 20)];
        _name.adjustsFontSizeToFitWidth = YES;
        _name.font = [UIFont systemFontOfSize:12];
        _name.textAlignment = NSTextAlignmentCenter;
        _name.textColor = [UIColor grayColor];
    }
    return _name;
}

- (UILabel *)count
{
    if (!_count)
    {
        _count = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.name.frame) - 30, 12, 16, 16)];
        _count.adjustsFontSizeToFitWidth = YES;
        _count.font = [UIFont systemFontOfSize:12];
        _count.backgroundColor = [UIColor redColor];
        _count.textColor = [UIColor whiteColor];
        _count.layer.masksToBounds = YES;
        _count.layer.cornerRadius = 8;
        _count.textAlignment = NSTextAlignmentCenter;
    }
    return _count;
}

@end
